#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<errno.h>
extern int errno;

main(int argc, char** argv)
{
  if(argc != 2)
  {
    fprintf(stderr,"Sintaxa apel: mkfifo nume_fifo\n");
    exit(1);
  }

  if( mknod(argv[1], S_IFIFO|0666, 0) == -1 )	/* sau: if( mkfifo(argv[1], 0666) == -1 ) */
  {
    if(errno == 17)   // 17 = errno for "File exists"
    {
       fprintf(stdout,"Note: fifo %s exista deja !\n",argv[1]);
       exit(0);
    }
    else
    {
       fprintf(stderr,"Error: creare fifo imposibila, errno=%d\n",errno);
       perror(0);
       exit(2);
    }
  }
}